package org.peoplesearch.pseindexer.processors;

import org.apache.solr.common.SolrInputDocument;
import org.peoplesearch.vk.utils.SerializableUser;

public class BaseInformationProcessor implements UserProcessor {

    @Override
    public void process(SolrInputDocument doc, SerializableUser user) {

        doc.addField("first_name", notNull(user.user.first_name));
        doc.addField("last_name", notNull(user.user.last_name));
        doc.addField("nickname", notNull(user.user.nickname));
        doc.addField("uid", notNull(user.user.uid));
        doc.addField("sex", notNull(user.user.sex));
        doc.addField("albums_count", notNull(user.user.albums_count));
        doc.addField("audios_count", notNull(user.user.audios_count));
        doc.addField("birthday", notNull(user.user.birthdate));
        doc.addField("city", notNull(user.user.city));
        doc.addField("country", notNull(user.user.country));
        doc.addField("graduation_year", notNull(user.user.graduation));
        doc.addField("nickname", notNull(user.user.nickname));
        doc.addField("photo", notNull(user.user.photo));
        doc.addField("photo_big", notNull(user.user.photo_big));
        doc.addField("photo_medium", notNull(user.user.photo_medium));
        doc.addField("timezone", notNull(user.user.timezone));
        doc.addField("domain", notNull(user.user.domain));
        doc.addField("university", notNull(user.user.university));
        doc.addField("university_name", notNull(user.user.university_name));
        doc.addField("faculty", notNull(user.user.faculty));
        doc.addField("faculty_name", notNull(user.user.faculty_name));
        doc.addField("has_mobile", notNull(user.user.has_mobile));
        doc.addField("home_phone", notNull(user.user.home_phone));
        doc.addField("mobile_phone", notNull(user.user.mobile_phone));
        doc.addField("status", notNull(user.user.status));
        doc.addField("relation", notNull(user.user.relation));
        doc.addField("friends_list_ids", notNull(user.user.friends_list_ids));
        doc.addField("videos_count", notNull(user.user.videos_count));
        doc.addField("notes_count", notNull(user.user.notes_count));
        doc.addField("friends_count", notNull(user.user.friends_count));
        doc.addField("user_photos_count", notNull(user.user.user_photos_count));
        doc.addField("user_videos_count", notNull(user.user.user_videos_count));

    }

    public String notNull(String in) {
        return (in == null) ? "" : in;
    }

    public Integer notNull(Integer in) {
        return (in == null) ? -1 : in;
    }

    public Boolean notNull(Boolean in) {
        return (in == null) ? false : in;
    }

    public Long notNull(Long in) {
        return (in == null) ? -1L : in;
    }
}
